home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-05
/
netpq203.zip
/
SHOWDATA.C
< prev
next >
Wrap
Text File
|
1993-03-05
|
7KB
|
308 lines
#include <stdio.h>
#include <conio.h>
#include "nos.h"
#include "noslib.h"
#include "netpq.h"
#include "proto.h"
extern struct serverdef *server;
extern struct localqueuedef *localqueue;
extern int currentserver, adaptornum, numberoflogins, currentprinter, found;
extern int queuejobcount, printjobcount;
extern int maxlocalqueuecount, localqueuecount;
extern int monoflag, timeout;
char *statusstring [] =
{
"FREE",
"UPDATING",
"HOLDING",
"WAITING",
"DESPOOLING",
"CANCELLED",
"FILE ERROR",
"SPOOL ERROR",
"* RUSH *"
};
int numberofprinterstrings = 6;
char *printerstring [] =
{
"LPT1:",
"LPT2:",
"LPT3:",
"COM1:",
"COM2:",
"ALL"
};
char *printerstatusstring [] =
{
"Disabled",
"Single",
"Enabled"
};
void reportinfo ()
{
//report server name & time
currentserver = 0;
while (currentserver < numberoflogins)
{
highlight ();
cprintf ("%-15s", server [currentserver] .servername);
nohighlight ();
cprintf ("%*s%02d/%02d/%04d %02d:%02d:%02d", 42,"",
server [currentserver] .time.TB_month,
server [currentserver] .time.TB_day,
server [currentserver] .time.TB_year,
server [currentserver] .time.TB_hour,
server [currentserver] .time.TB_minutes,
server [currentserver] .time.TB_seconds);
cprintf ("\r\n");
reportprinterstatus ();
reportprinterjobs ();
currentserver++;
}
}
void reportprinterstatus ()
{
// report status of each of the 5 printer ports on the server
currentprinter = 0;
while (currentprinter < 5)
{
if (server [currentserver] .PS_state_value [currentprinter] != 0)
{
highlight ();
cprintf ("%s ", printerstring [currentprinter]);
if (server [currentserver] .PS_state_pause [currentprinter] == 1)
{
highlightblink ();
cprintf ("%-10s", "Paused");
}
else
{
if (server [currentserver] .PS_index [currentprinter] < 65535)
{
if (server [currentserver] .PS_CPS [currentprinter] == 0)
highlightblink ();
cprintf ("%4d CPS ", server [currentserver] .PS_CPS [currentprinter]);
}
else
cprintf ("%-10s", printerstatusstring [server [currentserver] .PS_state_value [currentprinter] ]);
}
nohighlight ();
}
else
{
cprintf ("%s ", printerstring [currentprinter]);
cprintf ("Disabled ");
}
currentprinter++;
}
cprintf ("\r\n");
}
void reportprinterjobs ()
{
//report status of each printer job in the server's queue
int outputjobcount;
int hours, minutes;
int month, date, year;
DWORD percent;
printjobcount = 0;
outputjobcount = 0;
found = false;
while (printjobcount < localqueuecount)
{
if (localqueue [printjobcount] .server == currentserver)
{
if (found == false)
{
nohighlight ();
cprintf ("%-5s %-9s %-9s %-5s %-12s %-8s %11s %8s %3s",
"SEQ #", "USER NAME", "MACHINE", "TIME", "COMMENT",
"PRINTER", "STATUS", "SIZE", "PCT");
cprintf ("\r\n");
found = true;
}
choosecolor (localqueue [printjobcount] .qe .QE_status);
localqueue [printjobcount] .qe .QE_user [9] = '\0';
localqueue [printjobcount] .qe .QE_machine [9] = '\0';
localqueue [printjobcount] .qe .QE_comment [12] = '\0';
localqueue [printjobcount] .qe .QE_destination [8] = '\0';
hours = localqueue [printjobcount] .qe .QE_time / 0x0800;
minutes = (localqueue [printjobcount] .qe .QE_time & 0x07c0) / 0x0020;
year = localqueue [printjobcount] .qe .QE_date / 0x0200 + 1980;
month = (localqueue [printjobcount] .qe .QE_date & 0x01e0) / 0x0020;
date = localqueue [printjobcount] .qe .QE_date & 0x001f;
cprintf ("%-5lu", localqueue [printjobcount] .qe .QE_sequence);
cprintf (" %-9s", localqueue [printjobcount] .qe .QE_user);
cprintf (" %-9s", localqueue [printjobcount] .qe .QE_machine);
cprintf (" %02d:%02d", hours, minutes);
if (strlen (localqueue [printjobcount] .qe .QE_comment) > 0)
cprintf (" %-12s", localqueue [printjobcount] .qe .QE_comment);
else
cprintf (" %02d/%02d/%04d ", month, date, year);
cprintf (" %-8s", localqueue [printjobcount] .qe .QE_destination);
// If despooling, display number of bytes sent
if ( (localqueue [printjobcount] .qe .QE_status == 4) && (localqueue [printjobcount] .printer != -1) )
{
percent = 100 *
server [currentserver] .PS_output_chars [localqueue [printjobcount] .printer] /
localqueue [printjobcount] .qe .QE_size;
cprintf (" %8lu of", server [currentserver] .PS_output_chars [localqueue [printjobcount] .printer]);
cprintf (" %8lu", localqueue [printjobcount] .qe .QE_size);
cprintf (" %3lu", percent);
}
else
{
cprintf (" %11s", statusstring [localqueue [printjobcount] .qe .QE_status] );
cprintf (" %8lu", localqueue [printjobcount] .qe .QE_size);
cprintf (" 0");
}
cprintf ("\r\n");
outputjobcount++;
if ( (localqueuecount > (21 - (numberoflogins * 5))) &&
(outputjobcount > (21 - (numberoflogins * 5)) / numberoflogins))
{
errorhighlight ();
cprintf ("Total of %d files in queue\r\n", server [currentserver] .queue_jobs);
printjobcount = localqueuecount;
}
nohighlight ();
}
printjobcount++;
}
if (found == false)
{
cprintf ("No files spooled");
cprintf ("\r\n");
}
cprintf ("\r\n");
}
int getextch ()
{
// gets value of extended key press
int c;
c = getch ();
if (c == 0)
{
c = getch ();
if (c < 128)
c += 128;
}
return (c);
}
void highlight ()
{
// sets colors for active servers, and ports
if (!monoflag)
textcolor (BROWN);
highvideo ();
}
void nohighlight ()
{
// sets colors for server time & inactive ports
if (!monoflag)
textcolor (CYAN);
lowvideo ();
}
void highlightblink ()
{
// sets colors for paused and 0 CPS ports
if (!monoflag)
textcolor (RED + BLINK);
highvideo ();
}
void errorhighlight ()
{
// sets colors for error messages
if (!monoflag)
textcolor (RED);
highvideo ();
}
void choosecolor (int status)
{
// sets colors for queued files status
switch (status)
{
case 2:
nohighlight ();
if (!monoflag)
textcolor (RED);
break;
case 3:
case 8:
nohighlight ();
if (!monoflag)
textcolor (GREEN);
break;
case 4:
highlight ();
break;
default:
nohighlight ();
break;
}
}
void message (char *messagetext, int eraseflag)
{
// displays message in center of the first line of the screen
gotoxy ( (40 - (strlen (messagetext) / 2) ), 1);
errorhighlight ();
cprintf ("%s", messagetext);
nohighlight ();
if (eraseflag == true)
sleep (3);
}